#include <stdio.h>
int OGLD(int a, int b) 
{
	int t = 0;
	while (a%b!=0) 
	{
		t = a % b;
		a = b;
		b = t;
	}
	return b;
}
int main() 
{
	int a, b,ret;
	scanf_s("%d %d",&a,&b);
	ret = OGLD(a, b);
	printf("%d\n",ret);
	return 0;
}